﻿using B.S.Orders.Domain;
using B.S.Orders.ErrorCord;
using B.S.Orders.Read.Api.Application.Commands.DocumentsCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Orders.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DocumentsController : ControllerBase
    {
        private readonly IMediator mediator;

        public DocumentsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 查询显示生产单据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Documents>>> QueryDocuments([FromQuery] QueryDocumentsCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 反填生产单据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Documents>>> ShowDocuments([FromQuery] ShowDocumentsCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
